Public MustInherit Class Packet

#Region "Enums"
    Public Enum eServerOPCodes
        SM_AUTH = 0
        SM_LOGIN_FAIL = 1
        SM_ACCOUNT_BLOCKED = 2
        SM_LOGIN_OK = 3
        SM_SERVER_LIST = 4
        SM_SERVER_LIST_FAIL = 5
        SM_PLAY_FAIL = 6
        SM_PLAY_OK = 7
        SM_ACCOUNT_KICKED = 8
        SM_ACCOUNT_BLOCKED_WITH_MSG = 9

        SM_AUTH_GG = 11
        SM_UPDATE_SESSION = 12
    End Enum

    Public Enum eClientOPCodes
        CM_LOGIN = 0
        CM_PLAY = 2
        CM_LOGOUT = 3
        CM_SERVER_LIST = 5
        CM_AUTH_GG = 7
        CM_UPDATE_SESSION = 8
    End Enum
#End Region

#Region "Variables"
    Protected _params As List(Of Param)
#End Region

#Region "Packet Base"
    Public Overridable Function GenerateMessage() As Byte()
        Try
            Dim ms As New IO.MemoryStream
            Dim bw As New IO.BinaryWriter(ms)
            For Each p As Param In _params
                Select Case p.ParamDataType
                    Case Param.eDataType.Byte
                        bw.Write(CByte(p.ParamValue))
                    Case Param.eDataType.Short
                        bw.Write(CUShort(p.ParamValue))
                    Case Param.eDataType.Integer
                        bw.Write(CUInt(p.ParamValue))
                    Case Param.eDataType.String
                        bw.Write(Text.Encoding.Default.GetBytes(p.ParamValue), 0, p.ParamValue.Length)
                End Select
            Next
            Dim buff As Byte() = ms.ToArray
            bw.Close()
            ms.Close()
            ms.Dispose()
            Return buff
        Catch ex As Exception
            gLog.LogError(ex)
            Return Nothing
        End Try
    End Function
#End Region

    Public MustOverride Function GetPacketType() As String

End Class
